import React, { Component } from 'react';
import { Form, Input, Button, Select } from 'antd'
import { changeOrder } from '@/service/order';
import { history } from 'umi'

const formItemLayout = {
  labelCol: { span: 6 },
  wrapperCol: { span: 14 },
};
const onFinish = (values: any) => {
  const { orderid, status } = values
  changeOrder({ orderid, status}).then((res) => {
    console.log(res);
    history.push('/order/index')
  })
};

const { Option } = Select;
class changeOrders extends Component {
  constructor(props: any) {
    super(props)
  }
  // componentDidMount(){
  //     console.log(this.props.location.query.adminname);
  // }

  render() {

    return (
      <>
        <div>
          <Form
            name="validate_other"
            {...formItemLayout}
            onFinish={onFinish}
            initialValues={{
              'orderid': this.props.location.state.orderid,
              'status': ''
            }}
          >
            <Form.Item>
              <div style={{textAlign: 'center',width:'100%'}} className="ant-form-text">修改订单信息</div>
            </Form.Item>
            <Form.Item
              name="orderid"
              label="orderid"
              required
            >
              <Input size="large" disabled />
            </Form.Item>
            <Form.Item
              name="status"
              label="status"
              required
            >
              <Select defaultValue="订单状态" style={{ width: 120 }} allowClear>
                <Option value="0">未支付</Option>
                <Option value="1">待发货</Option>
                <Option value="2">待收货</Option>
                <Option value="3">待评价</Option>
                <Option value="4">已完成</Option>
              </Select>
            </Form.Item>
            <Form.Item wrapperCol={{ span: 12, offset: 6 }}>
              <Button type="primary" htmlType="submit">
                Submit
            </Button>
            </Form.Item>
          </Form>
        </div>
      </>
    );
  }
}

export default changeOrders;